<?php
include("../connection/connection.php");
//include("reportFunctions.php");
//$distId=418;//$_REQUEST['distId']
//$sqlReport = "SELECT distinct `district_id`,`district_name` FROM `tbl_lookup_location`";
//$queryReport = mysql_query($sqlReport);

$sqlReport1 = "SELECT distinct `user_id`,`user_type`,user_name FROM `tbl_dtls_user_history` where user_id!='' order by user_type";
$queryReport1 = mysql_query($sqlReport1);

function getUserCountQ1($userId,$action_id)
{
$queryForm="SELECT count(action_id) FROM `tbl_dtls_user_history` where action_id='".$action_id."' and user_id='".$userId."'" ;
$resultForm=mysql_query($queryForm);
$x=mysql_fetch_row($resultForm);
return $x[0];
}

?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Report</title>
</head>
<body>
<table border="0" width="879" cellspacing="0" cellpadding="0">
	<tr>
		<td width="919" height="26" bgcolor="#E9E9E9">
		<p align="center">
		<font face="Verdana" style="font-size: 9pt; font-weight: 700" color="#224568">
		User wise report which is entered by every user </font>
		<div align="center"><span style="font-size: 9pt; font-weight: 700">
      <font face="Verdana" color="#224568"> Table 2</font></span></div></td>
	</tr>
	<tr>
		<td bgcolor="#E9E9E9" height="56">
		<table border="1" width="879" cellspacing="0" cellpadding="0" height="49">
			
			<tr bgcolor="#C5D8EB">
			  <td width="42" align="center"><font style="font-size: 8.5pt" face="Verdana">Sr.No.</font></td>
			  <td width="140" align="center">
			  <p align="center"><font style="font-size: 8.5pt" face="Verdana">User Id</font></td>
				<td align="center" width="172"><font style="font-size: 8.5pt" face="Verdana">User Type</font> </td>
				<td align="center" width="160"><font style="font-size: 8.5pt" face="Verdana">User Name</font></td>
				<td align="center" width="55"><font style="font-size: 8.5pt" face="Verdana">Q1</font></td>
				<td align="center" width="56"><font style="font-size: 8.5pt" face="Verdana">Q2</font></td>
				<td align="center" width="57"><font style="font-size: 8.5pt" face="Verdana">Q3</font></td>
				<td align="center" width="64"><font style="font-size: 8.5pt" face="Verdana">CRITICAL</font></td>
				<td align="center" width="46"><font style="font-size: 8.5pt" face="Verdana">UFW</font></td>
				<td align="center" width="65"><font style="font-size: 8.5pt" face="Verdana">Total</font></td>
			</tr>
		 <?php
		     $i=1;  	
		 	while($rowReport1 = mysql_fetch_array($queryReport1)) {
			
			?>
			<tr bgcolor="#FFFFFF">
			  <td width="42" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $i++;  ?></font></td>
				<td width="140" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $rowReport1['user_id'];  ?></font></td>
				<td width="172" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $rowReport1['user_type'];  ?></font></td>
				<td width="160" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $rowReport1['user_name'];  ?></font></td>
				<td align="center" width="55"><font style="font-size: 8.5pt" face="Verdana"><?php echo getUserCountQ1($rowReport1['user_id'],1);?></font></td>
				<td align="center" width="56" ><font style="font-size: 8.5pt" face="Verdana"><?php echo getUserCountQ1($rowReport1['user_id'],2);?></font></td>
				<td align="center" width="57"><font style="font-size: 8.5pt" face="Verdana"><?php echo getUserCountQ1($rowReport1['user_id'],3);?></font></td>
				<td align="center" width="64"><font style="font-size: 8.5pt" face="Verdana"><?php echo getUserCountQ1($rowReport1['user_id'],7);?></font></td>
				<td align="center" width="46"><font style="font-size: 8.5pt" face="Verdana"><?php echo getUserCountQ1($rowReport1['user_id'],8);?></font></td>
				<td align="center" width="65"><font style="font-size: 8.5pt" face="Verdana"><?php echo (getUserCountQ1($rowReport1['user_id'],1)+getUserCountQ1($rowReport1['user_id'],2)+getUserCountQ1($rowReport1['user_id'],3)+getUserCountQ1($rowReport1['user_id'],7)+getUserCountQ1($rowReport1['user_id'],8));?></font></td>
			</tr>
			<?php
			}
			?>
		</table>
		</td>
	</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>


